#!/bin/sh
if [ $# -eq 0 ]; then
    sudo insmod ./blockDevice.ko
    echo "DEVICE_NAME by default"
    X=`grep blockDevice /proc/devices`
else
    sudo insmod ./blockDevice.ko DEVICE_NAME=${1}
    X=`grep $1 /proc/devices`
fi
if [ "$X" != "" ]; then
    set $X
    sudo rm  /dev/mblock
    sudo mknod /dev/mblock b $1 0
    sudo chmod 666 /dev/mblock
    sudo mkfs.ext2 -m0 /dev/mblock
    sudo mount -t ext2 /dev/mblock /mnt/minibd
else
    echo "Module $1 not loaded !"
    exit 1
fi
